package com.xiyue.leaspring.datasourceTest;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@ContextConfiguration(locations = {"classpath:spring/spring-jdbc6.xml"})
@RunWith(SpringJUnit4ClassRunner.class)//设置要测试的工具
public class DataSourceTest6 {
	
	private Logger logger = LoggerFactory.getLogger(DataSourceTest6.class);
	
	@Autowired
	private JdbcTemplate jdbcTemplate;
		
	@Test
	public void testDataSource() throws Exception {
		
		String sql = "DELETE FROM news WHERE nid=?";
		long nid = 3;
		int len = this.jdbcTemplate.update(sql,nid);//数据更新操作
		this.logger.info("更新行数："+len);
		
	}

}
